package com.example.map.mvpdemo.presenter;

import android.os.Handler;

import com.example.map.mvpdemo.bean.UserBean;
import com.example.map.mvpdemo.bizs.OnLoginListens;
import com.example.map.mvpdemo.bizs.UserBiz;
import com.example.map.mvpdemo.view.IUserView;

/**
 * Created by qundui on 2017/5/31.
 */
public class UserPresenter {
   IUserView iuserview;
    UserBiz userBiz;
    private Handler handler=new Handler();
    public UserPresenter(IUserView iuserview) {
        this.iuserview = iuserview;
        userBiz=new UserBiz();
    }
  public void Login(){
      iuserview.showpb();
      userBiz.Login(iuserview.getUsername(), iuserview.getPwd(), new OnLoginListens() {
          @Override
          public void LoginSucess(UserBean userBean) {
              handler.post(new Runnable() {
                  @Override
                  public void run() {
                      iuserview.hidepb();
                      iuserview.doBussiness();
                  }
              });
          }
          @Override
          public void LoginFail() {
              handler.post(new Runnable() {
                  @Override
                  public void run() {
                      iuserview.hidepb();
                      iuserview.Fail();
                  }
              });
          }
      });
  }

}
